#include <stdio.h>
// #include <stdlib.h>
#define FILENAME_FORMAT "file%d.txt"
#define WRITEWORDS  "唐佳的学习记录.\n第一次学习\n"

int main(void){
    FILE *fd = NULL;
    // size_t Nmemb = 1;

    for(int i = 1; i <= 100; i++){
        char filename[50];
        sprintf(filename, FILENAME_FORMAT, i);

        fd = fopen(filename, "a");
        if(fd == NULL){
            perror("open");
                return -1;
        }

        fwrite(WRITEWORDS, sizeof(char), sizeof(WRITEWORDS)-1, fd);
        fclose(fd);
        fd = NULL;
    }

    return 0;

    // printf("run start\n");
    // fd = fopen(FILENAME, "a");
    // if (fd == NULL){
    //     perror("open");
    //         return -1;
    // }
    // fwrite(WRITEWORDS, sizeof(WRITEWORDS), Nmemb, fd);
    // fclose(fd);
    // fd = NULL;
    // printf("run end\n");
    // while (1);
}